﻿-----------Dirty Read------------

--Cập nhật tình trạng cuốn sách
alter proc usp_CapNhatCuonSach
@isbn int,@ma_cuonsach int
as
begin tran
	update CuonSach
	set TinhTrang = 'Y'
	where isbn = @isbn AND Ma_CuonSach = @ma_cuonsach
	waitfor delay '00:00:15'
rollback tran
go

--Xem tình trạng cuốn sách
alter proc usp_XemCuonSach
@isbn int,@ma_cuonsach int
as
begin tran
	begin try
		waitfor delay '00:00:05'
		select * from CuonSach where isbn = @isbn AND Ma_CuonSach = @ma_cuonsach
	end try
	begin catch
		declare @error varchar(1000)
		set @error = N'Lỗi: ' + error_message()
		raiserror (@error,16,1)
		rollback tran
		return
	end catch
commit tran



